package niveis;

import java.awt.Color;

import br.com.engine.Vector2;
import br.com.engine.componentes.Animator;
import br.com.engine.componentes.GameObject;
import br.com.engine.componentes.Scene;
import br.com.engine.componentes.Sprite;
import br.com.engine.componentes.SpriteFont;
import br.com.engine.componentes.factory.SpriteFontFactory;
import br.com.engine.controle.ControleBase;
import br.com.engine.input.EventoTecla;
import br.com.engine.input.KeyMap;
import br.com.engine.input.TecladoAdapter;
import enumeracao.ScensEnum;

public class Map001 extends Scene
{
	GameObject obj;
	
	@Override
	public void setup() 
	{
		super.setup( );
		
		obj = new GameObject( );
		
		Sprite sp = new Sprite( "Person" );
		obj.addComponente( sp );

		Animator animator = new Animator( obj, 2, 1, 0, 100 );
		animator.creatAnimation( "down", 0, 1 );
		animator.play( "down" );
		
		add( obj );
		
		GameObject font  = SpriteFontFactory.newSpriteFont( "Teste Factory", new Vector2( 0, 0 )                  );
        GameObject font2 = SpriteFontFactory.newSpriteFont( "Teste Factory", 50, Color.RED, 15, SpriteFont.ITALIC );

        TecladoAdapter ta = TecladoAdapter.infNewInstacia( );
        
        ta.addkeyTiger( new EventoTecla( KeyMap.ESCAPE ) );
        
        ta.addOnPressed( evento -> 
        {
            if( evento.getKeyCode( ).equals( KeyMap.ESCAPE.getKey( ) ) )
            {
                ControleBase.getInstance( ).nextScene( ScensEnum.Pause.getNumero( ) );
            }
        } );
        
        add( font  );
        add( font2 );
	}
	
	@Override
	public void update( long time )
	{
	    super.update( time );
	    
	    Vector2 position = obj.getPosition( );
        
        position.setPositionPixel( position.getPositionPixel( ).x + 1, position.getPositionPixel( ).y + 1 );
	}
}